package com.bd.rj.frontstage.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bd.rj.common.entity.Comment;
import com.bd.rj.frontstage.service.impl.CommentServiceImpl;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("comment")
public class CommentController {
    @Resource
    private CommentServiceImpl commentService;

    /**
     * @author: WBW
     * 添加评论
     * @param comment
     * @return
     */
    @PostMapping("addcomment")
    public Map<String,Object> addComment(Comment comment){
        Map<String,Object> map = new HashMap<>();

        map.put("msg","success");
        map.put("code",200);
        map.put("data",commentService.save(comment));

        return map;
    }

    /**
     * @author: WBW
     * 根据企业id查询评论
     * @param eid 企业id
     * @return
     */
    @GetMapping("getcomment")
    public Map<String,Object> getComment(Long eid){
        Map<String,Object> map = new HashMap<>();
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("eid",eid);
        map.put("msg","success");
        map.put("code",200);
        map.put("data",commentService.list(queryWrapper));
        return map;
    }
}
